﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using System.Collections.ObjectModel;

namespace Catalyst.Web.DynamicData
{
    /// <summary>
    /// AndExpressionParameter evalutes a boolean AND operation against all parameters defined in the Parameters property.
    /// </summary>
    public class AndExpressionParameter : CompositeExpressionParameterBase
    {
        protected override Expression BuildBody(List<LambdaExpression> lambdas)
        {
            Expression root = lambdas[0].Body;
            for (int i = 1; i < lambdas.Count; i++)
            {
                root = Expression.MakeBinary(ExpressionType.And, root, lambdas[i].Body);
            }
            return root;
        }
    }
}
